home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / ASM / INTERUPT.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-11-18  |  3.6 KB  |  121 lines

  1. ;* INTERUPT.ASM
  2. ;************************************************************************
  3. ;*                                    *
  4. ;*        PC Scheme/Geneva 4.00 Borland TASM code            *
  5. ;*                                    *
  6. ;* (c) 1985-1988 by Texas Instruments, Inc. See COPYRIGHT.TXT        *
  7. ;* (c) 1992 by L. Bartholdi & M. Vuilleumier, University of Geneva    *
  8. ;*                                    *
  9. ;*----------------------------------------------------------------------*
  10. ;*                                    *
  11. ;*        Install interrupt handlers (Ctrl-C, Dos error)        *
  12. ;*                                    *
  13. ;*----------------------------------------------------------------------*
  14. ;*                                    *
  15. ;* Created by: John Jensen        Date: 1985            *
  16. ;* Revision history:                            *
  17. ;* - 18 Jun 92:    Renaissance (Borland Compilers, ...)            *
  18. ;*                                    *
  19. ;*                    ``In nomine omnipotentii dei''    *
  20. ;************************************************************************
  21. IDEAL
  22. %PAGESIZE    60, 132
  23. MODEL    medium
  24. LOCALS    @@
  25.  
  26.     INCLUDE    "scheme.ash"
  27.  
  28. SHIFT    =    04h            ; SHIFT in mode keys
  29. META    =    02h            ; ALT    "    "    "
  30. CNTRL    =    01h            ; CTRL    "    "    "
  31. C_KEY    =    54h            ; Scan code for 'C' key (84 decimal)
  32. BROKEY    =    64h            ; Scan code for 'PAUS/BRK' key (100 decimal)
  33.  
  34. ERR_INT    =    24h            ; Fatal error sabort address
  35. EXT_ERR    =    59h            ; Get Extended Error Code
  36. IBM_PBI    =    1bh            ; IBM Program Break Interrupt
  37.  
  38. CODESEG
  39.  
  40. kbm_int    DD    ?
  41. ferr_int DD    ?
  42.  
  43. ;************************************************************************
  44. ;*    Control-C fatal error                        *
  45. ;************************************************************************
  46. PROC    CTLC_INT
  47.     call    shft_brk        ; Signal break key
  48.     iret                ; Return like nothing happened 'cept
  49.                     ;    that a ^C<CR><LF> trio is displayed.
  50. ENDP    CTLC_INT
  51.  
  52. ;************************************************************************
  53. ;*    MSDOS fatal error                        *
  54. ;************************************************************************
  55. PROC    FAT_ERR
  56.     pop    ax            ; remove ip,cs, and flags of system regs from int 24h
  57.     pop    ax
  58.     pop    ax
  59.     xor    bx, bx            ; get extended error codes
  60.     mov    ah, EXT_ERR
  61.     int    MSDOS            ; Extended Error Code returned in ax
  62.     pop    bx            ; restore user registers at time of original function request 21h
  63.     pop    bx            ; Ignore old ax
  64.     pop    cx
  65.     pop    dx
  66.     pop    si
  67.     pop    di
  68.     pop    bp
  69.     pop    ds
  70.     pop    es            ; Set the carry bit in the caller's flags and return
  71.                     ; The original dos requestor should see that carry is set and
  72.                     ; that ax contains the error code
  73.     or    [BYTE bp-2], 1        ; toggle the carry flag
  74.     iret
  75. ENDP    FAT_ERR
  76.  
  77. ;************************************************************************
  78. ;*    setup fatal error handlers                    *
  79. ;************************************************************************
  80. PROC C    fix_intr USES ds si di
  81.     mov    ax, 3500h or IBM_PBI
  82.     int    MSDOS
  83.     mov    [WORD HIGH cs:kbm_int], es
  84.     mov    [WORD LOW cs:kbm_int], bx
  85.     mov    ax, 2500h or IBM_PBI
  86.     lea    dx, [CTLC_INT]
  87.     push    cs
  88.     pop    ds
  89.     int    MSDOS
  90.  
  91.     mov    ax, 2523h        ; This one doesn't need to be restored :
  92.     int    MSDOS            ; MS-DOS break handler
  93.  
  94. ;************************************************************************
  95. ;*    Install the handler for fatal error interrupt            *
  96. ;************************************************************************
  97.     mov    ax, 2500h or ERR_INT
  98.     int    MSDOS
  99.     mov    [WORD HIGH cs:ferr_int], es
  100.     mov    [WORD LOW cs:ferr_int], bx
  101.     mov    ax, 2500h or ERR_INT
  102.     lea    dx, [FAT_ERR]
  103.     int    MSDOS
  104.     ret
  105. ENDP    fix_intr
  106.  
  107. ;************************************************************************
  108. ;*    unsetup fatal error handlers                    *
  109. ;************************************************************************
  110. PROC C    unfixint USES ds si di
  111.     mov    ax, 2500h or IBM_PBI
  112.     lds    dx, [cs:kbm_int]
  113.     int    MSDOS
  114.     mov    ax, 2500h or ERR_INT
  115.     lds    dx, [cs:ferr_int]
  116.     int    MSDOS
  117.     ret
  118. ENDP    unfixint
  119.  
  120.     END
  121.